precision mediump float;

uniform sampler2D u_Image;
uniform sampler2D u_Noise;
uniform float u_Set;

varying vec2 v_uv;
varying vec3 v_normal;

void main(){
    float set = 200.0;
    vec2 uv = v_uv;
    uv.x *= set;
    uv.y *= set;
    uv.x = floor(uv.x);
    uv.y = floor(uv.y);
    uv.x /= set;
    uv.y /= set;

    float cur = texture2D(u_Noise, uv).x;
    vec4 image = texture2D(u_Image, v_uv);

    if(cur > u_Set){
        gl_FragColor = image;
    }else if(cur > u_Set - 0.015){
        gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
    }else{
        discard;
    }
    
}